package doorwifi.wd.patientsation.peripheral.mainapp.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;

import doorwifi.wd.patientsation.peripheral.mainapp.Bean.patientInfo;
import doorwifi.wd.patientsation.peripheral.mainapp.R;

/**
 * Created by xuhuan on 2017/7/11.
 */

public class patientInfoAdapter extends BaseAdapter {

    private Context mcontext;
    private ArrayList<patientInfo> mlist;
    private LayoutInflater layoutInflater;

    public patientInfoAdapter( Context mcontext,ArrayList<patientInfo> mlist) {

        this.mcontext = mcontext;
        this.mlist = mlist;
        layoutInflater = LayoutInflater.from(mcontext);
    }

    @Override
    public int getCount() {

        return mlist.size();
    }

    @Override
    public Object getItem(int position) {
        return mlist.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if(convertView == null){
            convertView = View.inflate(mcontext,R.layout.xh_call_sick_patient_info_layout,null);
            holder = new Holder();
            x.view().inject(holder,convertView);//注解绑定
            convertView.setTag(holder);
        }else {
            holder=(patientInfoAdapter.Holder) convertView.getTag();
        }
        holder.patientRoomAndBed.setText(mlist.get(position).getPatientRoom()+mlist.get(position).getPatientBed());
        holder.nameSexAndAge.setText(mlist.get(position).getName()+"  "+mlist.get(position).getSex()+"  "+mlist.get(position).getAge());


        holder.ruyuan_time.setText(mcontext.getResources().getString(R.string.xh_ruyuanTime)+mlist.get(position).getRuyuanTime());
        holder.zhuzhi_doctor.setText(mcontext.getResources().getString(R.string.xh_zhuzhi_doctor)+mlist.get(position).getZhuzhi_doctor());
        holder.nic.setText(mcontext.getResources().getString(R.string.xh_nic)+mlist.get(position).getNic());
        holder.theIllness.setText(mcontext.getResources().getString(R.string.xh_theIllness)+mlist.get(position).getTheIllness());
        holder.nursingLevel.setText(mcontext.getResources().getString(R.string.xh_nursingLevel)+mlist.get(position).getNursingLevel());
        holder.diet.setText(mcontext.getResources().getString(R.string.xh_diet)+mlist.get(position).getDiet());
        holder.allergy.setText(mcontext.getResources().getString(R.string.xh_allergy)+mlist.get(position).getAllergy());
        holder.quarantine.setText(mcontext.getResources().getString(R.string.xh_quarantine)+mlist.get(position).getQuarantine());

        return convertView;
    }

    private class Holder{
        @ViewInject(R.id.patientRoomAndBed)
        private TextView patientRoomAndBed;
        @ViewInject(R.id.nameSexAndAge)
        private TextView nameSexAndAge;
        @ViewInject(R.id.ruyuan_time)
        private TextView ruyuan_time;
        @ViewInject(R.id.zhuzhi_doctor)
        private TextView zhuzhi_doctor;
        @ViewInject(R.id.nic)
        private TextView nic;
        @ViewInject(R.id.theIllness)
        private TextView theIllness;
        @ViewInject(R.id.nursingLevel)
        private TextView nursingLevel;
        @ViewInject(R.id.diet)
        private TextView diet;
        @ViewInject(R.id.allergy)
        private TextView allergy;
        @ViewInject(R.id.quarantine)
        private TextView quarantine;
    }
}
